package com.voice.call.redis;

import java.util.Date;
import java.util.UUID;

import com.voice.call.utils.DateUtil;
import com.voice.call.utils.MD5Util;
import com.voice.call.utils.StringUtil;



public class RedisToken {
	
	
	private static final String Token_EncryKey = "#Z!c5HQ@fnkFURBw";
	private static final int Token_DayTimeOut = 30;
	
	private Integer id;
	private String token;
	private Date   tokenExpired;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public Date getTokenExpired() {
		return tokenExpired;
	}
	public void setTokenExpired(Date tokenExpired) {
		this.tokenExpired = tokenExpired;
	}
	
	public RedisToken() {
		
	}
	
    public RedisToken(Integer uid) {
		this.id = uid;
		String tokenStr = String.valueOf(uid) + UUID.randomUUID().toString() + StringUtil.buildRandomToken(10)+Token_EncryKey;
		this.token = MD5Util.md5Hex(tokenStr);
		Date nowDate = new Date();
		this.tokenExpired = DateUtil.addDate(nowDate, Token_DayTimeOut);
	}

}
